<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://img.mukewang.com/down/540812440001e40e00000000.js" type="text/javascript"></script>
<script src="http://img.mukewang.com/down/541f6ff70001a0a500000000.js" type="text/javascript"></script>

<title></title>
</head>
<body>

<script type="text/javascript">


function Callbacks(options) {
  var list = [];
  var self;
  self = {
    add: function(fn) {
      list.push(fn)
    },
    fire: function(args) {
      if(list){
        list.forEach(function(fn) {
          fn(args);
        })
        if(options === 'once'){
          list = undefined;
        }       
      }
    }
  }
  return self;
}


function fn1(val) {
  show('fn1 says:' + val);
}
function fn2(val) {
  show('fn2 says ' + val);
}


var cbs = Callbacks('once');
cbs.add(fn1);
cbs.fire('foo');
cbs.fire('foo');


</script>

</body>
</html>















